// interface 和 tpye 类似，但并不完全一致

interface Person {
  // 只读属性，不可更改
  // readonly name: string;
  name: string;
  // 可有可无属性
  age?: number;
  say(): string;
}

interface Teacher extends Person {
  teach(): string;
}

interface SayHi {
  (word: string): string;
}

const gerPersonName = (person: Person): void => {
  console.log(person.name);
};

const setPersonName = (person: Teacher, name: string): void => {
  person.name = name;
};

const person = {
  name: "dell",
  // age: 18,
  sex: "male",
  say() {
    return "say hello";
  },
  teach() {
    return "teach";
  },
};

gerPersonName(person);
setPersonName(person, "lee");

class User implements Person {
  name = "dell";
  say() {
    return "hello";
  }
}

const say: SayHi = (word: string) => {
  return word;
};
